package com.firebird.oms.domain.sm;

// Generated 2009-11-20 18:24:23 by Hibernate Tools 3.2.5.Beta

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 * TismFunction generated by hbm2java
 */
@Entity
@Table(name = "tism_function")
public class TismFunction implements java.io.Serializable {

	private static final long serialVersionUID = 3244725473508503932L;
	private Integer funcId;
	private String funcName;
	private String funcDesc;
	private Integer funcLevel;
	private Integer state;
	private Set<TismMenu> menus = new HashSet<TismMenu>(0);

	public TismFunction() {
	}

	public TismFunction(Integer funcLevel, Integer state) {
		this.funcLevel = funcLevel;
		this.state = state;
	}

	public TismFunction(String funcName, String funcDesc, Integer funcLevel,
			Integer state) {
		this.funcName = funcName;
		this.funcDesc = funcDesc;
		this.funcLevel = funcLevel;
		this.state = state;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "func_id", unique = true, nullable = false)
	public Integer getFuncId() {
		return this.funcId;
	}

	public void setFuncId(Integer funcId) {
		this.funcId = funcId;
	}

	@Column(name = "func_name", length = 64)
	public String getFuncName() {
		return this.funcName;
	}

	public void setFuncName(String funcName) {
		this.funcName = funcName;
	}

	@Column(name = "func_desc", length = 160)
	public String getFuncDesc() {
		return this.funcDesc;
	}

	public void setFuncDesc(String funcDesc) {
		this.funcDesc = funcDesc;
	}

	@Column(name = "func_level", nullable = false)
	public Integer getFuncLevel() {
		return this.funcLevel;
	}

	public void setFuncLevel(Integer funcLevel) {
		this.funcLevel = funcLevel;
	}

	@Column(name = "state", nullable = false)
	public Integer getState() {
		return this.state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	@ManyToMany(cascade = CascadeType.PERSIST)
	@LazyCollection(LazyCollectionOption.FALSE)
	@JoinTable(name = "tism_func_menu", joinColumns = { @JoinColumn(name = "func_id") }, inverseJoinColumns = @JoinColumn(name = "menu_code"))
	public Set<TismMenu> getMenus() {
		return menus;
	}

	public void setMenus(Set<TismMenu> menus) {
		this.menus = menus;
	}

	public boolean equals(final Object other) {
		if (!(other instanceof TismFunction))
			return false;
		TismFunction castOther = (TismFunction) other;
		return new EqualsBuilder().append(funcId, castOther.funcId).append(
				funcName, castOther.funcName).append(funcDesc,
				castOther.funcDesc).append(funcLevel, castOther.funcLevel)
				.append(state, castOther.state).append(menus, castOther.menus)
				.isEquals();
	}

	public int hashCode() {
		return new HashCodeBuilder().append(funcId).append(funcName).append(
				funcDesc).append(funcLevel).append(state).append(menus)
				.toHashCode();
	}

	public String toString() {
		return new ToStringBuilder(this).append("funcId", funcId).append(
				"funcName", funcName).append("funcDesc", funcDesc).append(
				"funcLevel", funcLevel).append("state", state).append("menus",
				menus).toString();
	}

}
